package netbay;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class CtrlFileManager {
	
	public String getAttachName(File ctrlFile) throws IOException
	{
		if(!ctrlFile.canRead())
		{
			System.out.println("error can't read file");
			return "";
		}
		else
		{
			BufferedReader reader = new BufferedReader(new FileReader(ctrlFile));
			
			String line = "";
			do
			{
					line = reader.readLine();
				
			}while(line != null && line.indexOf("PAYLOAD_NAME") == -1 );
			
			if(line == null)
			{
				System.out.println("error ctrl file has no payload_name");
				return "";				
			}
			else
			{
				return line.substring(13, line.length());
			}
		}
	}
	
	public TransactionLog readCtrlFile(File ctrlFile){
		return null;
	}
}
